<!-- 工单提示 -->

<template>
  <div class="page-box h100 display-flex czbj">
    <div class="n-card-header__main pm10">
      工单提示
    </div>
    <div>
      <dxtable  :pageSize="30" :headBtn="headBtn" :dataJson="dataJson" :portUrl="portUrl" :qx="qx"
        ref="databale" sonRouter="hhdetails" :hidebj="true" :isBfy="true">
      </dxtable>
    </div>
  </div>
</template>
<script lang="ts">
export default {
  name: "hhTicketPrompt",
};
</script>
<script lang='ts' setup>
import dxtable from "../../../components/util/dxtable.vue";
import sort from "../../../components/util/sort.vue";
import { dxget, dxpost, qurl, hf,transferTimeseer,handleDate,timeago } from "../../../util/index";
import { h, ref, reactive,onBeforeUpdate } from "vue";
import { NButton, NTime } from "naive-ui";
const props = defineProps({
  pup: { type: String },
});
const fusd = (row) => {
  const hredsd = window.location.href
  const text = hredsd.split("#/")[0] + `#/hhdetails?id=${row.order_id}&type=3&ck=3`
  navigator.clipboard.writeText(text);
  window.$message.success("复制成功")
}
let headBtn = [];
const zdList = ref()
const databale = ref();
const initeer = () => {
  databale.value.initDataExpose();
};
const taskListref = ref()
onBeforeUpdate(() => {
  try {
    initeer()
  } catch (e) {

  }
})

const format = 'yyyy年MM月dd日'
const emit = defineEmits(["callBack"]);
// 弹窗公用该列表
let dataJson = reactive([
  {
    title: "客户代码",
    key: "client_code",
    width: 80,
  },
  {
    title: "订单编号",
    key: "order_num",
    width: 220,
    render(row) {
      return h('span', {
        class: "ls sz", onClick: () => {
          fusd(row)
        }
      }, row.order_num)
    }
  }, {
    title: "订单日期",
    key: "date",
    type: "daterange",
    width: 120,
    render(row) {
      return transferTimeseer(row.date)
    }
  }, {
    title: "物料代码",
    key: "material_code",
  }, {
    title: "品名",
    key: "type_name",
  }, 
  {
    title: "完成品交期",
    key: "commit_date",
    type: "daterange",
    width: 120,
    // sorter: (row1, row2) => row1.commit_date - row2.commit_date,
    render(row) {
      let jnser = row.commit_date
      const currenTime = new Date().getTime()
      const commitdate = new Date(jnser).getTime()
      let maxsd = commitdate - currenTime
      let siurwef = transferTimeseer(jnser)  
      if (row.is_sent == 2) {
        return siurwef
      }
      if (maxsd < 0) {
        return h("div", { class: "bgred" }, siurwef)
      }
      if (maxsd < (1000 * 60 * 60 * 24 * 3)) {
        return h("div", { class: "bgyed" }, siurwef)
      }

      return siurwef
    }
  },

  {
    title: "超时类型",
    key: "out_type",
    render(row) {
        const sdrtrt = ['超时未分配工单','超时未开工','超时未完工']
        return sdrtrt[row.out_type-1]
    },
  }, 
  {
    title: "超时时长",
    key: "",
    render(row) {
      const dqse = new Date().getTime()
       return timeago(dqse-row.out_time_count *60 *1000)
    },
  }, 
  

  
]);
let portUrl = "hhscdd/orderMeg/gdts";

const qx = {
  DeletePermissionID: "hhTicketPromptdel22", //删除
  EditPermissionIdentifier: "hhTicketPromptbj22", // 编辑
  NewPermissionIdentifier: "hhTicketPromptxz22", // 新建
  ViewPermissionID: "hhTicketPromptck", // 查看
};


</script>
  
  